package Thread;

import java.util.Random;

class Run implements Runnable{
    @Override
    public void run() {
       while(true){
           try {
               Thread.sleep(1000);
               System.out.println("Hello Run");
           } catch (InterruptedException e) {
               throw new RuntimeException(e);
           }
       }
    }
}
public class ThreadDemo2 {
    public static void main(String[] args) {

        Run run=new Run();   //第二种方式创建一个类，实现Runnable接口，重写run方法
        Thread t=new Thread(run);
        t.start();
        while(true){
            try {
                Thread.sleep(1000);
                System.out.println("Hello Main");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

        }

    }
}
